﻿using System;
using System.Linq;
using System.Windows.Forms;

namespace BigEaterCh
{
  public partial class FormFirmy : FormZywienie
  {
    private static FormFirmy _instance;

    public static FormFirmy Pokaz(Form parentForm)
    {
      if (_instance != null)
      {
        _instance.RefreshDb();
      }
      else
      {
        _instance = new FormFirmy
        {
          MdiParent = parentForm
        };
      }
      return _instance;
    }


    private FormFirmy()
    {
      InitializeComponent();
      RefreshDb();
    }

    private void RefreshDb()
    {
      FormBigEaterCh.GetDataBase();
      this.firmyBindingSource.DataSource = FormBigEaterCh.Ze.Firmy;
    }

    private void FormProduktyFormClosing(object sender, FormClosingEventArgs e)
    {
      Hide();
      e.Cancel = true;
    }

    private void produktyBindingNavigatorSaveItem_Click(object sender, EventArgs e)
    {
      FormBigEaterCh.SaveDataBase();
      FormBigEaterCh.Ze.Refresh(System.Data.Objects.RefreshMode.StoreWins, FormBigEaterCh.Ze.Firmy);

    }

  }
}
